package com.rran.study.designpattern.behavioral.observer.listener.app;

import com.rran.study.designpattern.behavioral.observer.event.app.OrderEvent;
import com.rran.study.designpattern.behavioral.observer.model.OrderData;

/**
 * @author yy
 * @Type AppGenerateOrdersObserver.java
 * @Desc OrderEvent监听者---发单
 * @date 2020/7/21 19:35
 */
public class AppGenerateOrdersListener implements AppListener<OrderEvent> {

    @Override
    public void applicationEvent(OrderEvent event) {
         this.addOrder(event.getSource());
    }

    /**
     * 生成订单
     */
    private void addOrder(OrderData orderData) {
        System.out.println("订单观察者：生成订单成功。订单金额："+ orderData.getMoney()
                +"购买商品数：" + orderData.getBuyCount()+ "件");
    }

}
